<!DOCTYPE html>
<html lang="zh">

<head>
    <meta charset="utf-8">
    <link rel="stylesheet" href="style.css">
    <title>颜色滑动切换按钮</title>
    <style>
        .app {
            width: 100%;
            height: 100vh;
            background-color: #ffffff;
            position: relative;
            display: flex;
            justify-content: center;
            align-items: center;
        }

        .btn41 {
            width: 140px;
            height: 50px;
            font-size: 14px;
            font-weight: 700;
            border: none;
            background-color: #2c3754;
            color: #ffffff;
            position: relative;
            cursor: pointer;
            z-index: 0;
        }

        .btn41:before {
            content: '';
            width: 0;
            height: inherit;
            position: absolute;
            top: 0;
            left: 0;
            background-color: darkred;
            z-index: -1;
            transition: all 0.4s;
        }

        .btn41:hover:before {
            width: 100%;
        }
    </style>
</head>

<body>
    <div class="app">
        <button class="btn41">鼠标悬浮看效果</button>
    </div>
</body>

</html>